home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 170 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. From: jason@cygnus.com (Jason Merrill)
  2. Message-ID: <u9vilu8zvz.fsf@yorick.cygnus.com>
  3. X-Original-Date: 29 Jan 1996 13:17:04 -0800
  4. Path: in2.uu.net!bounce-back
  5. Date: 30 Jan 96 04:52:15 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Return-Path: <daemon@meeker.UCAR.EDU>
  8. Newsgroups: comp.std.c++
  9. Subject: Re: Observations on templates
  10. Organization: Cygnus Support, Mountain View, CA
  11. References: <ACVI83na99@qsar.chem.msu.su>
  12. In-Reply-To: "Eugene Radchenko"'s message of 29 Jan 96 10:38:37 GMT
  13. X-Newsreader: Gnus v5.0
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBFAgUBMQ2kHeEDnX0m9pzZAQHbawF/VzoUaPmjOk46E1MvJcY0cNlvDbjoEj8g
  16.     kNoSdG4TAAsbNQtfZ+4rIxQoBsYO0aor
  17.     =Osqu
  18.  
  19. >>>>> Eugene Radchenko <eugene@qsar.chem.msu.su> writes:
  20.  
  21. > 1) Clause [temp.res] verse 1 requires that all types dependent on the
  22. > template parameter must be qualified by 'typename' keyword - supposedly to
  23. > allow checking the template syntax. But it does not help anything as _each_
  24. > instance will have to be checked anyway:
  25.  
  26. Requiring 'typename' allows syntactic analysis and some name binding
  27. to be done at the point of definition of the template.  Older
  28. implementations do all name binding at the point of instantiation,
  29. which was thought to be confusing.
  30.  
  31. Each instance will indeed have to be checked, but only for semantic
  32. correctness, not syntactic.
  33.  
  34. > 2) Clause [temp.dep] verse 5 states that base class scope names hide the
  35. > template parameter:
  36.  
  37. This is for orthogonality.  Think of the template header as creating a
  38. special scope around the class; name lookups in class scope look in the
  39. current class, then in base classes, then in the surrounding scope.
  40.  
  41. Note that template parameters used as base types are not affected by this
  42. rule, since name binding is done on the template definition, before the
  43. base is known.
  44.  
  45. > 3) Clause [temp.arg.explicit] verses 2-3 requires that for explicit arg in
  46. > member template to be present it must be qualified by 'template' keyword,
  47. > e.g.
  48. >      X *p; p->template alloc<200>();
  49. > But to use operator -> we need X class definition anyway - so we know that
  50. > alloc() is a template.
  51.  
  52. It is needed in some situations where we do not have the X class definition
  53. -- in template definitions, like with typename.
  54.  
  55. Jason
  56. ---
  57. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  58.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  59.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  60.